//数值型小数保留小数位
Number.prototype.fixed = function (len) {
    len = isNaN(len) ? 0 : len
    var num = Math.pow(10, len)
    return Math.round(this * num) / num
}


String.prototype.endWith = function (s) {
    if (s == null || s == "" || this.length == 0 || s.length > this.length)
        return false;
    if (this.substring(this.length - s.length) == s)
        return true;
    else
        return false;
    return true;
}


String.prototype.startWith = function (s) {
    if (s == null || s == "" || this.length == 0 || s.length > this.length)
        return false;
    if (this.substr(0, s.length) == s)
        return true;
    else
        return false;
    return true;
}

//分割数组，用于分批发送匹配的请求
var splitArr = (data, senArrLen) => {
    //处理成len个一组的数据
    let data_len = data.length;
    let arrOuter_len = data_len % senArrLen === 0 ? data_len / senArrLen : parseInt((data_len / senArrLen) + '') + 1;
    let arrSec_len = data_len > senArrLen ? senArrLen : data_len; //内层数组的长度
    let arrOuter = new Array(arrOuter_len); //最外层数组
    let arrOuter_index = 0; //外层数组的子元素下标
    // console.log(data_len % len);
    for (let i = 0; i < data_len; i++) {
        if (i % senArrLen === 0) {
            arrOuter_index++;
            let len = arrSec_len * arrOuter_index;
            //将内层数组的长度最小取决于数据长度对len取余，平时最内层由下面赋值决定
            arrOuter[arrOuter_index - 1] = new Array(data_len % senArrLen);
            if (arrOuter_index === arrOuter_len) //最后一组
                data_len % senArrLen === 0 ?
                len = data_len % senArrLen + senArrLen * arrOuter_index :
                len = data_len % senArrLen + senArrLen * (arrOuter_index - 1);
            let arrSec_index = 0; //第二层数组的索引
            for (let k = i; k < len; k++) { //第一层数组的开始取决于第二层数组长度*当前第一层的索引
                arrOuter[arrOuter_index - 1][arrSec_index] = data[k];
                arrSec_index++;
            }
        }
    }
    return arrOuter;
};